<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>三要素关系理解</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: #f5f5f5;
            padding: 15px;
            line-height: 1.5;
        }

        .container {
            max-width: 900px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border: 1px solid #ddd;
        }

        .title {
            text-align: center;
            color: #333;
            margin-bottom: 20px;
            font-size: 24px;
            font-weight: bold;
        }

        .formula-section {
            background: #007bff;
            color: white;
            padding: 20px;
            margin-bottom: 20px;
            text-align: center;
        }

        .formula-display {
            font-size: 28px;
            font-weight: bold;
            margin-bottom: 15px;
        }

        .formula-parts {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 15px;
            flex-wrap: wrap;
        }

        .formula-part {
            background: rgba(255,255,255,0.2);
            padding: 10px 15px;
            min-width: 80px;
            text-align: center;
            transition: all 0.3s ease;
        }

        .formula-part.highlighted {
            background: rgba(255,255,255,0.9);
            color: #333;
            transform: scale(1.05);
        }

        .operator {
            font-size: 24px;
            font-weight: bold;
        }

        .main-content {
            display: grid;
            grid-template-columns: 300px 1fr;
            gap: 20px;
            margin-bottom: 20px;
        }

        .controls-panel {
            background: #f8f8f8;
            padding: 15px;
        }

        .controls-title {
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 15px;
            color: #333;
        }

        .control-group {
            margin-bottom: 15px;
            padding: 10px;
            background: white;
            border: 1px solid #ddd;
        }

        .control-label {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
            font-size: 14px;
        }

        .control-name {
            font-weight: bold;
            color: #555;
        }

        .control-value {
            background: #007bff;
            color: white;
            padding: 3px 8px;
            font-weight: bold;
            font-size: 12px;
        }

        .slider {
            width: 100%;
            height: 4px;
            background: #ddd;
            outline: none;
            -webkit-appearance: none;
        }

        .slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            background: #007bff;
            cursor: pointer;
        }

        .slider::-moz-range-thumb {
            width: 16px;
            height: 16px;
            background: #007bff;
            cursor: pointer;
            border: none;
        }

        .visual-panel {
            background: white;
            border: 1px solid #ddd;
        }

        .visual-header {
            background: #333;
            color: white;
            padding: 10px;
            text-align: center;
            font-weight: bold;
        }

        .chart-container {
            padding: 20px;
            height: 200px;
            display: flex;
            align-items: flex-end;
            justify-content: space-around;
            background: #fafafa;
        }

        .bar-group {
            display: flex;
            flex-direction: column;
            align-items: center;
            flex: 1;
        }

        .bar {
            width: 40px;
            height: 120px;
            background: #eee;
            position: relative;
            margin-bottom: 8px;
            border: 1px solid #ddd;
        }

        .bar-fill {
            width: 100%;
            position: absolute;
            bottom: 0;
            transition: height 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            font-size: 12px;
        }

        .efficiency-fill {
            background: #ff6b6b;
        }

        .time-fill {
            background: #4ecdc4;
        }

        .total-fill {
            background: #45b7d1;
        }

        .bar-label {
            font-weight: bold;
            color: #333;
            font-size: 12px;
            margin-top: 5px;
        }

        .relationship-display {
            background: #fff3cd;
            color: #856404;
            padding: 12px;
            text-align: center;
            font-weight: bold;
            margin-top: 15px;
        }

        .scenarios-section {
            background: #f8f8f8;
            padding: 15px;
            margin-top: 20px;
        }

        .scenarios-title {
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 10px;
            color: #333;
        }

        .scenario-item {
            margin: 8px 0;
            padding: 8px;
            background: white;
            border-left: 3px solid #007bff;
            font-size: 13px;
        }

        @media (max-width: 768px) {
            .main-content {
                grid-template-columns: 1fr;
                gap: 15px;
            }
            
            .formula-parts {
                flex-direction: column;
                gap: 8px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1 class="title">工程问题三要素关系</h1>

        <div class="formula-section">
            <div class="formula-display">效率 × 时间 = 工作总量</div>
            <div class="formula-parts">
                <div class="formula-part" id="efficiency-part">
                    <div>效率</div>
                    <div id="efficiency-display">5</div>
                </div>
                <div class="operator">×</div>
                <div class="formula-part" id="time-part">
                    <div>时间</div>
                    <div id="time-display">6</div>
                </div>
                <div class="operator">=</div>
                <div class="formula-part" id="total-part">
                    <div>总量</div>
                    <div id="total-display">30</div>
                </div>
            </div>
        </div>

        <div class="main-content">
            <div class="controls-panel">
                <div class="controls-title">参数调节</div>
                
                <div class="control-group">
                    <div class="control-label">
                        <span class="control-name">工作效率</span>
                        <span class="control-value" id="efficiency-value">5 件/小时</span>
                    </div>
                    <input type="range" min="1" max="10" value="5" class="slider" id="efficiency-slider">
                </div>

                <div class="control-group">
                    <div class="control-label">
                        <span class="control-name">工作时间</span>
                        <span class="control-value" id="time-value">6 小时</span>
                    </div>
                    <input type="range" min="1" max="12" value="6" class="slider" id="time-slider">
                </div>

                <div class="control-group">
                    <div class="control-label">
                        <span class="control-name">工作总量</span>
                        <span class="control-value" id="total-value">30 件</span>
                    </div>
                    <div style="font-size: 12px; color: #666; margin-top: 5px;">
                        自动计算结果
                    </div>
                </div>
            </div>

            <div class="visual-panel">
                <div class="visual-header">关系图表</div>
                <div class="chart-container">
                    <div class="bar-group">
                        <div class="bar">
                            <div class="bar-fill efficiency-fill" id="efficiency-bar">5</div>
                        </div>
                        <div class="bar-label">效率</div>
                    </div>
                    
                    <div class="bar-group">
                        <div class="bar">
                            <div class="bar-fill time-fill" id="time-bar">6</div>
                        </div>
                        <div class="bar-label">时间</div>
                    </div>
                    
                    <div class="bar-group">
                        <div class="bar">
                            <div class="bar-fill total-fill" id="total-bar">30</div>
                        </div>
                        <div class="bar-label">总量</div>
                    </div>
                </div>
            </div>
        </div>

        <div class="relationship-display" id="relationship-text">
            效率5 × 时间6 = 总量30
        </div>

        <div class="scenarios-section">
            <div class="scenarios-title">工程应用场景</div>
            <div class="scenario-item">
                <strong>生产制造：</strong>机器每小时生产效率 × 工作时间 = 产品总数量
            </div>
            <div class="scenario-item">
                <strong>建筑施工：</strong>施工队每日进度 × 工作天数 = 工程总进度
            </div>
            <div class="scenario-item">
                <strong>运输物流：</strong>车辆运载效率 × 运输时间 = 运输总量
            </div>
            <div class="scenario-item">
                <strong>数据处理：</strong>处理器每秒运算量 × 运行时间 = 处理数据总量
            </div>
        </div>
    </div>

    <script>
        // 状态变量
        let efficiency = 5;
        let time = 6;
        let total = 30;
        
        // DOM 元素
        const elements = {
            efficiencySlider: document.getElementById('efficiency-slider'),
            timeSlider: document.getElementById('time-slider'),
            efficiencyValue: document.getElementById('efficiency-value'),
            timeValue: document.getElementById('time-value'),
            totalValue: document.getElementById('total-value'),
            efficiencyDisplay: document.getElementById('efficiency-display'),
            timeDisplay: document.getElementById('time-display'),
            totalDisplay: document.getElementById('total-display'),
            efficiencyBar: document.getElementById('efficiency-bar'),
            timeBar: document.getElementById('time-bar'),
            totalBar: document.getElementById('total-bar'),
            relationshipText: document.getElementById('relationship-text'),
            efficiencyPart: document.getElementById('efficiency-part'),
            timePart: document.getElementById('time-part'),
            totalPart: document.getElementById('total-part')
        };

        // 初始化
        function init() {
            updateAllValues();
            elements.efficiencySlider.addEventListener('input', handleEfficiencyChange);
            elements.timeSlider.addEventListener('input', handleTimeChange);
        }

        // 处理效率变化
        function handleEfficiencyChange() {
            efficiency = parseInt(elements.efficiencySlider.value);
            total = efficiency * time;
            updateAllValues();
            highlightChange('efficiency');
        }

        // 处理时间变化
        function handleTimeChange() {
            time = parseInt(elements.timeSlider.value);
            total = efficiency * time;
            updateAllValues();
            highlightChange('time');
        }

        // 更新所有数值显示
        function updateAllValues() {
            // 更新控制面板
            elements.efficiencyValue.textContent = `${efficiency} 件/小时`;
            elements.timeValue.textContent = `${time} 小时`;
            elements.totalValue.textContent = `${total} 件`;
            
            // 更新公式显示
            elements.efficiencyDisplay.textContent = efficiency;
            elements.timeDisplay.textContent = time;
            elements.totalDisplay.textContent = total;
            
            // 更新柱状图
            updateBars();
            
            // 更新关系提示
            elements.relationshipText.textContent = `效率${efficiency} × 时间${time} = 总量${total}`;
        }

        // 更新柱状图
        function updateBars() {
            const maxEfficiency = 10;
            const maxTime = 12;
            const maxTotal = 120;
            
            const efficiencyHeight = (efficiency / maxEfficiency) * 100;
            const timeHeight = (time / maxTime) * 100;
            const totalHeight = (total / maxTotal) * 100;
            
            elements.efficiencyBar.style.height = `${efficiencyHeight}%`;
            elements.timeBar.style.height = `${timeHeight}%`;
            elements.totalBar.style.height = `${totalHeight}%`;
            
            elements.efficiencyBar.textContent = efficiency;
            elements.timeBar.textContent = time;
            elements.totalBar.textContent = total;
        }

        // 高亮变化效果
        function highlightChange(type) {
            // 移除之前的高亮
            elements.efficiencyPart.classList.remove('highlighted');
            elements.timePart.classList.remove('highlighted');
            elements.totalPart.classList.remove('highlighted');
            
            // 添加新的高亮
            if (type === 'efficiency') {
                elements.efficiencyPart.classList.add('highlighted');
                setTimeout(() => elements.efficiencyPart.classList.remove('highlighted'), 800);
            } else if (type === 'time') {
                elements.timePart.classList.add('highlighted');
                setTimeout(() => elements.timePart.classList.remove('highlighted'), 800);
            }
            
            // 总量总是会变化
            elements.totalPart.classList.add('highlighted');
            setTimeout(() => elements.totalPart.classList.remove('highlighted'), 800);
        }

        // 启动应用
        init();
    </script>
</body>
</html>